package org.expressme.webwind.renderer;

import java.io.PrintWriter;

import javax.servlet.ServletContext;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.json.simple.JSONObject;

public class JsonRenderer extends Renderer {

	private JSONObject jsonObject;
	
	public JsonRenderer(JSONObject jsonObject  )
	{
		this.jsonObject=jsonObject;
	}
	
	@Override
	public void render(ServletContext context, HttpServletRequest request, HttpServletResponse response) throws Exception {
	        response.setContentType("application/json;;charset=UTF-8");
	        PrintWriter pw = response.getWriter();
	        pw.write(jsonObject.toJSONString());
	        pw.flush();
	}

}
